package com.tender;

import com.tender.constants.Constants;
import com.tender.integration.config.properties.WebSocketProperties;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
//import org.apache.rocketmq.client.consumer.store.LocalFileOffsetStore;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import com.tender.integration.config.properties.MsgProperties;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

import java.util.UUID;

@EnableWebSocket  // 这个不能忘记了。
@SpringBootApplication
@EnableEncryptableProperties
@MapperScan("com.tender.mapper")
@EnableConfigurationProperties({MsgProperties.class, WebSocketProperties.class})
public class WebSocketServerApplication {

    public static void main(String[] args) {
        System.setProperty("jasypt.encryptor.password", "wb-csd876509");
        //动态服务名
        System.setProperty(Constants .APPLICATION_NAME, Constants.APPLICATION_NAME_PREFIX + UUID.randomUUID());

        /**
         * 参考文章：https://juejin.cn/post/7133511198284185636 如何定制本地 rocketmq_offset 文件路径
         * @see LocalFileOffsetStore 该类里面有关于广播时候的本地 rocketmq_offset 文件的配置
         */

        /*
         * 指定使用的日志框架，否则将会告警
         * RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.InternalThreadLocalMap).
         * RocketMQLog:WARN Please initialize the logger system properly.
         */
        // System.setProperty("rocketmq.client.logUseSlf4j", "true");
        // System.setProperty("rocketmq.client.logLevel", "ERROR");
        /**
         * 参考文献：https://blog.csdn.net/H_Sino/article/details/138991758  （SpringBoot 整合 WebSocket）
         * 高并发时候的问题：The remote endpoint was in state [xxxx] which is an invalid state for calle
         * 问题复现：https://blog.csdn.net/abu935009066/article/details/131218149
         *
         * 解决方案：ConcurrentWebSocketSessionDecorator 来包装 WebSocketSession
         */
        // System.setProperty("rocketmq.client.localOffsetStoreDir","D:/.rocketmq_offset");
        ConfigurableApplicationContext applicationContext = SpringApplication.run(WebSocketServerApplication.class, args);
    }

}